Repository navigation
fix(truapi): retry native preimage lookups after a miss - #1673
Merged
Merged
Conversation
The native shim sent the app's first lookup_preimage answer and then waited for notifyPreimageChanged, which neither the iOS nor the Android app calls. Both apps answer a failed fetch with a miss, so a lookup whose first fetch failed never resolved. After a miss, the shim calls lookup_preimage again, 6 seconds apart and backing off to 30, until it gets bytes that hash to the key. An app error ends the retries and reaches the product. Keys that are not 32 bytes are not retried. Fixes #1219
…onds The product SDK's lookup helpers wait 20 seconds (NFT artwork) and 30 seconds (cloud storage) before giving up. Doubling the pause from 6 seconds retried only twice in that time, at 6 and 18 seconds. The native lookup now retries every 6 seconds for the first five retries, then every 30 seconds. That gives three retries within 20 seconds and five within 30, and keeps lookups a product holds open at one request every 30 seconds.
A product dials the bridge and opens preimage_lookup_subscribe, so the frames go through dispatch, the runtime's hash check and the native retry. The tests check that a lookup whose first fetch failed gets the value once the host has it, that bytes which do not hash to the key never reach the product, and that a Stop frame or a closed connection ends the retries.
Contributor
|
CI Status: 25 required jobs green, 22 passed and 3 skipped by path filter. All job results
Signing credentials: valid as of 2026-10-26 Commit |
Contributor
Bundle size reportCompared with
WebAssembly modules
Changed files (1)
Commit: 9fdd492 |
pgherveou
reviewed
Oct 26, 2026
pgherveou
approved these changes
Oct 26, 2026
pgherveou
left a comment
Collaborator
There was a problem hiding this comment.
approve to unblock - with some comments
The retry decision matched on the GenericError the host error had already been turned into. It now matches on HostRejection, so a new variant would force a decision, and the conversion to GenericError happens once where the stream is assembled.
A preimage key is a blake2b-256 digest, but PreimageHost took a Vec<u8>, so the native shim and the CLI each checked the length. The runtime now answers a key of any other length with a miss itself, and every platform gets a [u8; 32]. The native callback and the JS host callback still take bytes, so apps and dotli need no change.
5 tasks
…ookup-retry # Conflicts: # rust/crates/truapi/src/native/platform.rs
Mikelle
enabled auto-merge
October 26, 2026 10:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1219
On iOS and Android, a preimage lookup whose first fetch failed never got the value. After the first answer the native shim only forwarded
notifyPreimageChanged, and neither app calls it.After a miss,
CallbackPlatform::lookup_preimageasks the app again every 6 s for the first 30 s, which covers the product SDK's lookup timeouts, then every 30 s. It stops when the app returns bytes that hash to the key, returns an error, or the product unsubscribes. Keys that are not 32 bytes are not retried. The apps need no changes.Tested with
cargo test -p truapi(new tests innative/tests.rs).